package com.yonyou.crm.cum.customer.appctrl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.crm.common.login.context.LoginContextConstant;
import com.yonyou.crm.common.rest.util.ResponseUtil;
import com.yonyou.crm.cum.customer.rmitf.ICustomerRmService;
import com.yonyou.iuap.context.InvocationInfoProxy;

@RestController
@RequestMapping(value = "/{version}/mcum/customers")
public class AppCustomerFuncCtrl {
	
	@Autowired
	private ICustomerRmService service;
	
	/**
	 * 获取客户列表上动作列表
	 * @param version
	 * @param id
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "listactions", method = RequestMethod.GET)
	public Object getCustomerFuncList(@PathVariable("version") String version,
			HttpServletRequest request, HttpServletResponse response){
		String roleIdStr = InvocationInfoProxy.getParameter(LoginContextConstant.RoleId);
		Long roleId = Long.parseLong(roleIdStr);
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("roleId", roleId);
		param.put("funcnode", "customer");
		Map<String, List<String>> frMap = service.getCustomerFuncList(param);
		JSONObject result = new JSONObject();
		result.put("data", frMap);
		return ResponseUtil.getObject(result);
	}
}
